package com.pdsu.xpf.graduation01.dao;

import com.pdsu.xpf.graduation01.domain.Admin;
import com.pdsu.xpf.graduation01.domain.FeedBack;
import com.pdsu.xpf.graduation01.domain.User;
import com.pdsu.xpf.graduation01.vo.OrderVO;
import com.pdsu.xpf.graduation01.vo.UserVO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface UserDao {



    @Select("select * from user")
    List<User> findAllUser();

    @Select("select * from user where username = #{Username} and password = #{Password} ")
    User findUserByUsernameAPassword(String Username,String Password);

    @Select("select * from user where username = #{Username}")
    User findUserByUsername(String Username);

    //更新用户token

    @Update("UPDATE user set token = #{token} WHERE uid = #{uid}")
    int upDateUserTokenByUserID(String token,int uid);

    //保存注册用户
    @Insert("INSERT into user(username,name,password,phone,token,registerdate) VALUES (#{username},#{name},#{password},#{phone},#{token},#{date})")
    int insertUser(String username,String name,String password,String phone,String token,String date);

    @Select("select * from user where uid = #{uid}")
    User findUserByUID(int uid);
    @Select("select * from user ")
    List<UserVO> findAllUserVO();

    @Select("select * from feedback as fed,user where user.uid = fed.uid ")
    List<FeedBack> findAllFeedBack();


    @Delete("delete from feedback where fid = #{fid}")
    Integer delFeedBackByFID(int fid);

    @Select("select * from user where username like #{key}")
    List<UserVO> searchUserByKey(String key);

    @Select("select * from admin where admin = #{name} and password = #{password}")
    List<Admin> adminLogin(String name, String password);

    @Insert("insert into feedback(fname,phone,content,date,uid) values(#{fname},#{phone},#{msg},#{date},#{uid})")
    Integer addFeedBack(String fname, String msg, String uid, String phone, String date);

    @Update("update user set recent = #{date} where uid = #{uid}")
    Integer updateUserDATEBYUID(int uid,String date);
}
